package shopping.feign01.interceptor;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.StringUtils;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class AuthInterceptor implements HandlerInterceptor {
  private static final Logger log = LoggerFactory.getLogger(AuthInterceptor.class);
  
  @Override
  public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
    // 逻辑认证
    String authorization = request.getHeader("Authorization");
//    log.info("获取的认证信息 Authorization：{}", authorization);
    if (StringUtils.hasText(authorization)) {
      return true;
    }
    return false;
  }
}
